package severlet;

import bean.Guarantee;
import dao.GuaranteeDao;
import service.StudenService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

@WebServlet(name = "StudentGuaranteeServlet", value = "/StudentGuaranteeServlet")
public class StudentGuaranteeServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");

//调用数据库
        GuaranteeDao guaranteeDao=new GuaranteeDao();

//        根据宿舍号查询维修信息信息
        String sessionDormId = (String) request.getSession().getAttribute("dormitoryid");
        ArrayList<Guarantee> guaranteesList = guaranteeDao.getGuaranteesByDormitoryid2();

        //存入session中
        request.getSession().setAttribute("guarntee",guaranteesList);
        request.getRequestDispatcher("student_guarantee.jsp").forward(request,response);
    }
}
